package client;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import pojo.ResponseResult;
import pojo.asset.IsComplete;
import pojo.asset.asset.Asset;
import pojo.asset.asset.AssetClasses;
import pojo.asset.assetImport.AssetImport;
import pojo.asset.assetImport.AssetImportResult;
import pojo.asset.assetMaintenance.AssetMaintenance;
import pojo.asset.assetMaintenance.AssetMaintenanceResult;
import pojo.asset.assetOutbound.AssetOutbound;
import pojo.asset.assetOutbound.AssetOutboundResult;
import pojo.asset.assetRetirement.AssetRetirement;
import pojo.asset.assetRetirement.AssetRetirementResult;
import pojo.asset.assetSecondment.AssetSecondment;
import pojo.asset.assetSecondment.AssetSecondmentResult;
import pojo.asset.assetSecondment.AssetSecondmentStatus;
import pojo.asset.repository.Repository;

import java.util.List;

/**
 * @author HGD
 * @date 2022/10/7 23:44
 */
@FeignClient("asset")
public interface AssetClient {

    //--------------------------
    //未入库资产批量导入

    @PostMapping("/assetManager/getExcelData")
    ResponseResult<Object> getExcelAsset(@RequestBody String importData);


    //------------------------------------------------------------------------------------------------
    // 资产入库

    /**
     * 资产管理员获取未入库资产集合
     *
     * @return 未入库资产集合
     */
    @PostMapping("/assetManager/getUnassignedAsset")
    ResponseResult<List<Asset>> getUnassignedAsset();

    /**
     * 资产管理员查询对应资产可入库的仓库列表
     *
     * @param assetId 对应资产
     * @return 可入库的仓库列表
     */
    @PostMapping("/assetManager/getEnableImportRepositories")
    ResponseResult<List<Repository>> getEnableImportRepositories(@RequestParam("assetId") Long assetId);

    /**
     * 资产管理员创建资产入库申请
     *
     * @param assetId        资产id
     * @param assetManagerId 资产管理员id
     * @param repositoryId   仓库id
     * @return 剩余未分库资产
     */
    @PostMapping("/assetManager/insertAssetImport")
    ResponseResult<List<Asset>> insertAssetImport(@RequestParam("assetId") Long assetId,
                                                  @RequestParam("assetManagerId") Long assetManagerId,
                                                  @RequestParam("repositoryId") Long repositoryId);

    /**
     * 资产管理员获取资产入库申请
     *
     * @param assetManagerId 资产管理员id
     * @return 入库申请
     */
    @PostMapping("/assetManager/amGetAssetImport")
    ResponseResult<List<AssetImport>> amGetAssetImport(@RequestParam("assetManagerId") Long assetManagerId);

    /**
     * 仓管获取入库申请列表
     *
     * @param repoManagerId 仓管id
     * @return 入库申请列表
     */
    @PostMapping("/repoManager/getAssetImports")
    ResponseResult<List<AssetImport>> getAssetImports(@RequestBody Long repoManagerId);

    /**
     * 仓管审批入库申请
     *
     * @param assetImportId 资产入库申请id
     * @param result        入库申请结果
     * @return 剩余入库申请
     */
    @PostMapping("/repoManager/updateAssetImport")
    ResponseResult<String> updateAssetImport(@RequestParam("assetImportId") Long assetImportId,
                                             @RequestParam("result") AssetImportResult result);

    //-------------------------------------------------------------------------------------------------------------------------
    // 资产借调

    /**
     * 资产借调人员获取所有的可借资产
     *
     * @return 可借资产种类和名称
     */
    @PostMapping("/applicant/getAllowBorrowAssets")
    ResponseResult<List<Asset>> getAllowBorrowAssets();

    /**
     * 借调人员获取借调记录
     *
     * @param applicantId 借调人员id
     * @return 借调记录
     */
    @PostMapping("/applicant/getAssetSecondments")
    ResponseResult<List<AssetSecondment>> getAssetSecondments(@RequestBody Long applicantId);

    /**
     * 借调人员创建借调申请
     *
     * @param assetName        借调资产名称
     * @param classes          借调资产种类
     * @param applicantId      借调人员id
     * @param secondmentReason 借调理由
     * @param status           借调种类
     * @return 借调人员的借调记录
     */
    @PostMapping("/applicant/insertAssetSecondment")
    ResponseResult<List<AssetSecondment>> insertAssetSecondment(@RequestParam("assetName") String assetName,
                                                                @RequestParam("classes") AssetClasses classes,
                                                                @RequestParam("applicantId") Long applicantId,
                                                                @RequestParam("secondmentReason") String secondmentReason,
                                                                @RequestParam("status") AssetSecondmentStatus status);

    /**
     * 部门审批人员获取资产借用申请
     *
     * @param userIds 该部门所有成员id
     * @return 资产借用申请
     */
    @PostMapping("/approve/apGetAssetSecondments")
    ResponseResult<List<AssetSecondment>> apGetAssetSecondments(@RequestBody List<Long> userIds);

    /**
     * 部门审批人员审批借用申请
     *
     * @param assetSecondmentId 借用申请id
     * @param result            审批结果
     * @return 本部门资产借用申请
     */
    @PostMapping("/approve/apUpdateAssetSecondment")
    ResponseResult<String> apUpdateAssetSecondment(@RequestParam("assetSecondmentId") Long assetSecondmentId,
                                                   @RequestParam("result") AssetSecondmentResult result);

    /**
     * 信息管理经理获取调用申请
     *
     * @return 调用申请列表
     */
    @PostMapping("/information/ifGetAssetSecondments")
    ResponseResult<List<AssetSecondment>> ifGetAssetSecondments();

    /**
     * 信息管理经理审批借用申请
     *
     * @param assetSecondmentId 调用申请id
     * @param result            审批结果
     * @return 审批是否通过
     */
    @PostMapping("/information/ifUpdateAssetSecondment")
    ResponseResult<String> ifUpdateAssetSecondment(@RequestParam("assetSecondmentId") Long assetSecondmentId,
                                                   @RequestParam("result") AssetSecondmentResult result);

    /**
     * 分管领导获取资产借调申请
     *
     * @return 借调申请
     */
    @PostMapping("/chargeLeader/clGetAssetSecondment")
    ResponseResult<List<AssetSecondment>> clGetAssetSecondments();

    /**
     * 分管领导审批借调申请
     *
     * @param assetSecondmentId 调用申请id
     * @param result            审批结果
     * @return 审批是否通过
     */
    @PostMapping("/chargeLeader/clUpdateAssetSecondment")
    ResponseResult<String> clUpdateAssetSecondment(@RequestParam("assetSecondmentId") Long assetSecondmentId,
                                                   @RequestParam("result") AssetSecondmentResult result);

    /**
     * 财务人员获取资产借调申请
     *
     * @return 借调申请
     */
    @PostMapping("/financial/clGetAssetSecondment")
    ResponseResult<List<AssetSecondment>> flGetAssetSecondments();

    /**
     * 财务人员审批借调申请
     *
     * @param assetSecondmentId 调用申请id
     * @param result            审批结果
     * @return 审批是否通过
     */
    @PostMapping("/financial/clUpdateAssetSecondment")
    ResponseResult<String> flUpdateAssetSecondment(@RequestParam("assetSecondmentId") Long assetSecondmentId,
                                                   @RequestParam("result") AssetSecondmentResult result);

    /**
     * 运维人员获取资产借调申请
     *
     * @return 资产借调申请
     */
    @PostMapping("/operations/opGetAssetSecondments")
    ResponseResult<List<AssetSecondment>> opGetAssetSecondments();

    /**
     * 运维人员审批资产借调申请
     *
     * @param assetSecondmentId 资产借调申请id
     * @param result            审批结果
     * @return 是否修改成功
     */
    @PostMapping("/operations/opUpdateAssetSecondments")
    ResponseResult<String> opUpdateAssetSecondments(@RequestParam("assetSecondmentId") Long assetSecondmentId,
                                                    @RequestParam("result") AssetSecondmentResult result);

    /**
     * 资产管理员获取资产借调申请
     *
     * @param assetManagerId 资产管理员id
     * @return 资产借调申请
     */
    @PostMapping("/assetManager/amGetAssetSecondments")
    ResponseResult<List<AssetSecondment>> amGetAssetSecondments(@RequestParam("assetManagerId") Long assetManagerId);

    /**
     * 资产管理员获取可分配资产
     *
     * @param assetSecondmentId 资产借调申请id
     * @return 可分配资产
     */
    @PostMapping("/assetManager/getUnLockAssets")
    ResponseResult<List<Asset>> getUnLockAssets(@RequestParam("assetSecondmentId") Long assetSecondmentId);

    /**
     * 资产管理员为借调申请分配资产并创建资产出库
     *
     * @param assetId           资产id
     * @param assetSecondmentId 借调申请id
     * @param assetManagerId    资产管理员id
     * @return 是否成功
     */
    @PostMapping("/assetManager/insertAssetOutbound")
    ResponseResult<String> insertAssetOutbound(@RequestParam("assetId") Long assetId,
                                               @RequestParam("assetSecondmentId") Long assetSecondmentId,
                                               @RequestParam("assetManagerId") Long assetManagerId);

    /**
     * 资产管理员获取资产出库申请
     *
     * @param assetManagerId 资产管理员id
     * @return 出库申请
     */
    @PostMapping("/assetManager/amGetAssetOutbounds")
    ResponseResult<List<AssetOutbound>> amGetAssetOutbounds(@RequestParam("assetManagerId") Long assetManagerId);

    /**
     * 仓管获取出库申请
     *
     * @param repoManagerId 仓库管理员id
     * @return 出库申请
     */
    @PostMapping("/repoManager/rmGetAssetOutbounds")
    ResponseResult<List<AssetOutbound>> rmGetAssetOutbounds(@RequestParam Long repoManagerId);

    /**
     * 仓管审批出库申请
     *
     * @param id     出库审批id
     * @param result 审批结果
     * @return 是否审批成功
     */
    @PostMapping("/repoManager/rmUpdateAssetOutbound")
    ResponseResult<String> rmUpdateAssetOutbound(@RequestParam("id") Long id,
                                                 @RequestParam("result") AssetOutboundResult result);

    /**
     * 资产管理员更新出库申请
     *
     * @param assetSecondmentId 资产借调id
     * @param isComplete        是否完成
     * @return 是否审批成功
     */
    @PostMapping("/assetManager/amUpdateAssetOutbound")
    ResponseResult<String> amUpdateAssetOutbound(@RequestParam("assetSecondmentId") Long assetSecondmentId,
                                                 @RequestParam("isComplete") IsComplete isComplete);

    /**
     * 资产管理员更新资产借调申请
     *
     * @param assetSecondmentId 资产借调申请id
     * @param result            判断结果
     * @return 是否成功
     */
    @PostMapping("/assetManager/amUpdateAssetSecondment")
    ResponseResult<String> amUpdateAssetSecondment(@RequestParam("assetSecondmentId") Long assetSecondmentId,
                                                   @RequestParam("result") AssetSecondmentResult result);


    /**
     * 申请人根据资产种类获取资产列表
     *
     * @param classes 资产种类
     * @return 资产列表
     */
    @PostMapping("/applicant/getAllowBorrowAssetsByClasses")
    ResponseResult<List<Asset>> getAllowBorrowAssetsByClasses(@RequestParam("classes") AssetClasses classes);

    //------------------------------------------------------------------------------------------------------------------------
    // 资产维修

    /**
     * 申请人获取资产维修列表
     *
     * @param applicantId 申请人id
     * @return 资产维系列表
     */
    @PostMapping("/applicant/apGetAssetMaintenance")
    ResponseResult<List<AssetMaintenance>> apGetAssetMaintenance(@RequestParam("applicantId") Long applicantId);

    /**
     * 申请人创建资产维修
     *
     * @param assetId     资产id
     * @param applicantId 申请人id
     * @return 是否创建成功
     */
    @PostMapping("/applicant/apInsertAssetMaintenance")
    ResponseResult<Boolean> apInsertAssetMaintenance(@RequestParam("assetId") Long assetId,
                                                     @RequestParam("applicantId") Long applicantId);

    /**
     * 运维人员获取资产维修申请列表
     *
     * @return 资产维修申请列表
     */
    @PostMapping("/operations/opGetAssetMaintenance")
    ResponseResult<List<AssetMaintenance>> opGetAssetMaintenance();

    /**
     * 运维人员审批维修申请
     *
     * @param assetMaintenanceId 申请id
     * @param result             审批结果
     * @return 是否审批成功
     */
    @PostMapping("/operations/opUpdateAssetMaintenance")
    ResponseResult<Boolean> opUpdateAssetMaintenance(@RequestParam("assetMaintenanceId") Long assetMaintenanceId,
                                                     @RequestParam("result") AssetMaintenanceResult result);

    /**
     * 资管获取资产维修申请
     *
     * @param assetManagerId 资产管理员id
     * @return 维修申请
     */
    @PostMapping("/assetManager/amGetAssetMaintenance")
    ResponseResult<List<AssetMaintenance>> amGetAssetMaintenance(@RequestParam("assetManagerId") Long assetManagerId);

    /**
     * 资管根据资产id获取资产信息
     *
     * @param assetId 资产id
     * @return 资产信息
     */
    @PostMapping("/assetManager/getAssetByAssetId")
    ResponseResult<Asset> getAssetByAssetId(@RequestParam("assetId") Long assetId);

    /**
     * 资管审批维修申请
     *
     * @param assetMaintenanceId 维修申请id
     * @param result             审批结果
     * @param assetManagerId     资产管理员id
     * @return 是否成功
     */
    @PostMapping("/assetManager/amUpdateAssetMaintenance")
    ResponseResult<Boolean> amUpdateAssetMaintenance(@RequestParam("assetMaintenanceId") Long assetMaintenanceId,
                                                     @RequestParam("result") AssetMaintenanceResult result,
                                                     @RequestParam("assetManagerId") Long assetManagerId);

    //-------------------------------------------------------------------------------------------------------------------------------------------------------
    // 资产报废

    /**
     * 申请人获取资产报废申请
     *
     * @param applicantId 申请人id
     * @return 资产报废申请
     */
    @PostMapping("/applicant/apGetAssetRetirement")
    ResponseResult<List<AssetRetirement>> apGetAssetRetirement(@RequestParam("applicantId") Long applicantId);

    /**
     * 申请人创建资产报废申请
     *
     * @param assetId     资产id
     * @param applicantId 申请人id
     * @return 创建资产报废是否成功
     */
    @PostMapping("/applicant/apInsertAssetRetirement")
    ResponseResult<Boolean> apInsertAssetRetirement(@RequestParam("assetId") Long assetId,
                                                    @RequestParam("applicantId") Long applicantId);

    /**
     * 运维人员查询资产报废申请
     *
     * @return 资产报废申请
     */
    @PostMapping("/operations/opGetAssetRetirement")
    ResponseResult<List<AssetRetirement>> opGetAssetRetirement();

    /**
     * 运维人员创审批资产报废申请
     *
     * @param assetRetirementId 申请id
     * @param result            审批结果
     * @return 审批是否成功
     */
    @PostMapping("/operations/opUpdateAssetRetirement")
    ResponseResult<Boolean> opUpdateAssetRetirement(@RequestParam("assetRetirementId") Long assetRetirementId,
                                                    @RequestParam("result") AssetRetirementResult result);

    /**
     * 资产管理人员查询资产报废申请
     *
     * @param assetManagerId 资产管理员id
     * @return 资产报废申请
     */
    @PostMapping("/assetManager/amGetAssetRetirement")
    ResponseResult<List<AssetRetirement>> amGetAssetRetirement(@RequestParam("assetManagerId") Long assetManagerId);

    /**
     * 资产管理人员审批资产报废申请
     *
     * @param assetRetirementId 资产报废申请id
     * @param result            审批结果
     * @param assetManagerId    资产管理员id
     * @return 是否成功
     */
    @PostMapping("/assetManager/amUpdateAssetRetirement")
    ResponseResult<Boolean> amUpdateAssetRetirement(@RequestParam("assetRetirementId") Long assetRetirementId,
                                                    @RequestParam("result") AssetRetirementResult result,
                                                    @RequestParam("assetManagerId") Long assetManagerId);

    //--------------------------------------------------------------------------------------------------------------------------------------------------
    // 资产盘点

    /**
     * 资产管理人员获取可盘点申请
     *
     * @return 可盘点资产集合
     */
    @PostMapping("/assetManager/getInventoryAsset")
    ResponseResult<List<Asset>> getInventoryAsset();

}
